package com.xzzz.irda.auth.core.exception;

import com.xzzz.common.base.BaseProperties;
import com.xzzz.common.base.exception.AbstractExceptionAdvice;
import com.xzzz.common.base.exception.XzAbstractException;
import com.xzzz.common.base.pojo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@Order(-1)
@RestControllerAdvice
public class ExceptionAdviceByAuth extends AbstractExceptionAdvice {

    public ExceptionAdviceByAuth(BaseProperties baseProperties) {
        super(baseProperties);
    }

    @ExceptionHandler(AuthException.class)
    public R<?> authInvalidClientIdExceptionHandler(XzAbstractException exception) {
        printExLog(exception, exception.getMessage());
        return R.fault(exception.getCode(), exception.getMessage());
    }
}
